package com.gupaoedu.pattern.sigleton.lazy;

/**
 * @Auther: tcm
 * @Date: 2020/1/23 14:50
 * @Description:
 */
public class LazySingleton {

    private static LazySingleton singleton;

    private LazySingleton(){
        if(singleton!=null){
            throw new RuntimeException("不能创建多个单例！！！");
        }
    }

    public LazySingleton getInstance(){
        if(singleton == null){
            synchronized (LazySingleton.class){
                if(singleton == null){
                    singleton = new LazySingleton();
                }
            }
        }
        return singleton;
    }

}
